import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { basVenListData } from '/@/api/bas/ven/basVen';

const { t } = useI18n('sys.basVen');

const modalProps = {
  title: t('供应商选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 90,
  schemas: [
    {
      label: t('供应商编码'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('供应商名称'),
      field: 'name',
      component: 'Input',
    },
    {
      label: t('供应商简称'),
      field: 'venAbbName',
      component: 'Input',
    },
    {
      label: t('联系人'),
      field: 'venPerson',
      component: 'Input',
    },
    {
      label: t('联系电话'),
      field: 'venHand',
      component: 'Input',
    },
    {
      label: t('地址'),
      field: 'venAddress',
      component: 'Input',
    },
    {
      label: t('状态'),
      field: 'status',
      component: 'Select',
      componentProps: {
        dictType: 'sys_search_status',
        allowClear: true,
      },
    },
    {
      label: t('备注'),
      field: 'remarks',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('供应商编码'),
    dataIndex: 'code',
    key: 'a.code',
    sorter: true,
    width: 130,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('供应商名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('供应商分类'),
    dataIndex: 'basVenCls.clsName',
    key: 'a.cls_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('供应商简称'),
    dataIndex: 'venAbbName',
    key: 'a.ven_abb_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('联系人'),
    dataIndex: 'venPerson',
    key: 'a.ven_person',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('联系电话'),
    dataIndex: 'venHand',
    key: 'a.ven_hand',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('地址'),
    dataIndex: 'venAddress',
    key: 'a.ven_address',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_search_status',
  },
  {
    title: t('邮箱'),
    dataIndex: 'venEmail',
    key: 'a.ven_email',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('更新时间'),
    dataIndex: 'updateDate',
    key: 'a.update_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('备注'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: basVenListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'code',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'name',
};
